package com.syc.ssm.dao.impl;

import java.sql.SQLException;

import javax.annotation.Resource;

import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

import com.syc.ssm.dao.IUserDao;
import com.syc.ssm.domain.User;

/*
 * 三层架构的Dao层实现
 */

//SqlSessionDaoSupport:类中封装了session对象
@SuppressWarnings("restriction")
@Repository("userDao")
public class UserDaoImpl extends SqlSessionDaoSupport 
	implements IUserDao {

	//SqlSessionTemplate implements SqlSession
	//SqlSessionFactory sqlSessionFactory;

	//给setSqlSessionFactory()方法中的SqlSessionFactory对象赋值
	@Resource
	public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
		super.setSqlSessionFactory(sqlSessionFactory);
	}
	
	// 添加用户
	public void insertUser(User user) throws SQLException {
		getSqlSession().insert(User.class.getName() + ".insertUser", user);
	}

	public User findUser(User user) throws SQLException {

		return null;
	}

}
